package er;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class NumberFourteen {
    public static void main(String[] args) {
        try(
                FileOutputStream fileOutputStream=new FileOutputStream("g:/file/qiege/pinjie.mp4");
                FileInputStream fileInputStream1=new FileInputStream("G:/file/qiege/sui1.txt");
                FileInputStream fileInputStream2=new FileInputStream("G:/file/qiege/sui2.txt");
                FileInputStream fileInputStream3=new FileInputStream("G:/file/qiege/sui3.txt");
                FileInputStream fileInputStream4=new FileInputStream("G:/file/qiege/sui4.txt");
        ) {
            byte[] bytes=new byte[1048576];
            List<FileInputStream> list=new ArrayList<>();
            list.add(fileInputStream1);
            list.add(fileInputStream2);
            list.add(fileInputStream3);
            list.add(fileInputStream4);
            while (true)
            {
                int count=0;
                for (FileInputStream fileInputStream : list) {
                    int read=fileInputStream.read(bytes);
                    if (read!=-1){
                        fileOutputStream.write(bytes,0,read);
                    }else if (read==-1){
                        count++;
                    }
                }
                if (count==4){
                    break;
                }
            }


        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
